package org.sixtynine.stock.service.impl;

import java.util.Date;
import java.util.List;

import org.sixtynine.stock.dao.AspiDataDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.AspiData;
import org.sixtynine.stock.service.AspiDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AspiDataServiceImpl implements AspiDataService {

	@Autowired
	private AspiDataDao aspiDataDao;

	@Override
	public AspiData findById(int id) {
		return aspiDataDao.findById(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void saveAspiData(AspiData aspiData) {
		aspiDataDao.saveAspiData(aspiData);

	}

	@Override
	@Transactional(readOnly = false)
	public void deleteAspiData(int id) {
		AspiData aspiData = aspiDataDao.findById(id);
		if (aspiData != null) {
			aspiDataDao.delete(aspiData);
		}
	}

	@Override
	public List<AspiData> findAspiData(Date date) {
		return aspiDataDao.findAspiData(date);
	}

	@Override
	public List<AspiData> searchMonthlyAspiData( Date fromDate,
			Date toDate ,  String orderBy) {
		return aspiDataDao.searchMonthlyAspiData(fromDate, toDate , orderBy);
	}

	@Override
	public Page<AspiData> searchMonthlyAspiData( Date fromDate,
			Date toDate, String orderBy, GridPramDTO gridPramDTO) {
		return aspiDataDao.searchMonthlyAspiData( fromDate, toDate,
				orderBy ,gridPramDTO);
	}

	@Override
	public void deleteAspiData(Date fromDate, Date toDate) {
		aspiDataDao.deleteAspiData(fromDate ,toDate);
	}

}
